//
//  BottomView.m
//  Mtime
//
//  Created by Mac on 15/8/5.
//  Copyright (c) 2015年 wxk. All rights reserved.
//

#import "BottomView.h"

@implementation BottomView
{
    
    
    NSArray *_dataList;//加载的数据
    
    NSArray *_array1;//特色数据
    
    NSArray *_array2;//商圈数据
    
    NSArray *_array3;//地区数据
    
    NSArray *_array4;//地铁数据


}

- (void)loadData {

    _dataList = [[NSArray alloc] init];
    
    
    _array1 = @[@"全部",@"IMAX厅",@"中国巨幕",@"4K放映厅",@"3D厅",@"杜比全景声厅",@"情侣座",@"停车场",@"Wi-Fi"];
    
    _array2 = @[@"全部",@"美食广场",@"恒隆广场"];

    
    _array3 = @[@"全部",@"历下区",@"市中区",@"槐荫区",@"商河区",@"历城区",@"长清区"];
    
    _array4 = [[NSArray alloc] init];
    
    _dataList = _array1;

    [_collectionView reloadData];
    
}

//加载xib文件时调用的方法
- (void)awakeFromNib {

    [super awakeFromNib];

    [self loadData];
    
    _imageV.hidden = YES;
    
    _segmentView.titles = @[@"特色",@"商圈",@"地区",@"地铁"];
    _segmentView.selectImageName = @"icon_slider_min";
    
    [_segmentView addBlcok:^(NSInteger index) {
       
        if (index == 0) {
            
            _dataList = _array1;
            [_collectionView reloadData];
        }else if (index == 1) {
        
            _dataList = _array2;
            [_collectionView reloadData];
        }else if (index == 2) {
        
            _dataList = _array3;
            [_collectionView reloadData];
        }else {
        
            _dataList = _array4;
            [_collectionView reloadData];
        }
        
    }];
    
    //加载collection view
    _collectionView.dataSource = self;
    _collectionView.delegate = self;
    
    [_collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"cell"];
}

#pragma mark UICollectionViewDataSource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {

    _imageV.hidden = YES;
    
    if (_dataList.count == 0) {
        
        _imageV.image = [UIImage imageNamed:@"bus"];
        _imageV.contentMode = UIViewContentModeScaleAspectFit;
        _imageV.hidden = NO;
    }
    
    return _dataList.count;

}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {

    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
    
    cell.contentView.backgroundColor = [UIColor redColor];
    
    UILabel *label = [[UILabel alloc] initWithFrame:cell.contentView.bounds];
    
    label.text = _dataList[indexPath.item];
    
    label.backgroundColor = [UIColor whiteColor];
    label.textAlignment = NSTextAlignmentCenter;
    
    [cell.contentView addSubview:label];
    
    
    return cell;
    
}

- (IBAction)cancelAction:(UIButton *)sender {
    
    [UIView animateWithDuration:.2 animations:^{
        
        self.transform = CGAffineTransformIdentity;
    }];

    
}
@end
